﻿using System;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using DataHelper;

namespace DAL
{
  public  class RoleDao
    {

        
      //获取该账号 所有的角色
        public DataTable GetUserRole(string account)
        {
            string sql = "select * from Sys_Account_Role where  Account='" + account + "'";
            return SQLHelper.ExecuteSqlGetDrToDt(sql);
        }
        //获取该角色的所有菜单
        public DataTable GetMenuByRole(string sysRoleID)
        {
            return SQLHelper.ExecuteSqlGetDrToDt("select * from JimView_Role_Menu Where SysRoleID='" + sysRoleID + "' and State='Y' order by MainMenuID ASC");
        }
        //设置right
        public bool SetMenuRight(ArrayList menuArray, string strRight, string rangeLimit)
        {
            bool flag = true;
            if (menuArray.Count > 0)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (object accountMenuID in menuArray)
                {
                    stringBuilder.Append("update Sys_SysRoleMenu Set RightLimit='" + strRight + "',RangeLimit='" + rangeLimit + "'  Where SysRoleMemuID=" + accountMenuID.ToString() + ";");
                }
                string strSQL = stringBuilder.ToString();
                if (!string.IsNullOrEmpty(strSQL))
                    flag = SQLHelper.ExecuteSql(stringBuilder.ToString());
                else
                    flag = false;
            }
            else
            {
                flag = false;

            }
            return flag;
        }

        
    }
}
